import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入全屏滚动插件
import VueFullPage from 'vue-fullpage.js'
import './common/css/common.css'
//引入阿里巴巴字体图标
import './assets/iconfont/iconfont.css'
//引入elementUi
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
//引入markdown编辑器
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
//引入echart
import * as echarts from 'echarts'
Vue.prototype.echarts = echarts
    //引入axios
import axios from 'axios'
//markdown前端显示
import hljs from 'highlight.js'
import 'highlight.js/styles/dark.css' //引入代码高亮的css
//使用cookie
import Cookies from 'js-cookie'

//markdown前端显示封装成一个指令
Vue.directive('highlight', (el) => {
    let blocks = el.querySelectorAll('pre code')
    blocks.forEach((block) => {
        hljs.highlightBlock(block)
    })
})

axios.defaults.baseURL = "http://localhost:99/api"

//设置事件过滤器
import moment from 'moment'

axios.interceptors.request.use(config => {
    config.headers.Authorization = window.sessionStorage.getItem('token')
    config.headers['Cache-Control'] = 'no-cache'
    return config
}, (err) => {
    return Promise.reject(err);
})

Vue.prototype.$http = axios
Vue.prototype.Cookies = Cookies
Vue.filter('time', function(value, formatString) {
    formatString = formatString || 'YYYY-MM-DD HH:mm'
    return moment(value).format(formatString)
})

Vue.config.productionTip = false
Vue.use(VueFullPage)
Vue.use(ElementUI)
Vue.use(mavonEditor)

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')